package com.example.demo.controller;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AbstractIgnoreExceptionReadListener;
import com.alibaba.excel.metadata.CellData;
import com.example.demo.model.ExcelModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * @author huangzhuoguang
 * @Description
 * @date 2021/1/6
 */
@RestController
@RequestMapping("readExcel")
public class ReadExcelController {
    @GetMapping(value = "readExcel")
    public List<ExcelModel> readExcel(MultipartFile file) throws IOException {
        EasyExcel.read(file.getInputStream(), ExcelModel.class, new AbstractIgnoreExceptionReadListener<ExcelModel>() {
            @Override
            public void invokeHead(Map<Integer, CellData> headMap, AnalysisContext context) {

            }

            @Override
            public void invoke(ExcelModel data, AnalysisContext context) {

            }

            @Override
            public void doAfterAllAnalysed(AnalysisContext context) {

            }
        }).sheet().doRead();

        return null;
    }
}
